package com.xbongbong.saas.enums.business;

import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.paas.enums.FieldTypeEnum;
import com.xbongbong.paas.enums.ScreenTypeEnum;
import com.xbongbong.saas.enums.SelectProductEnum;
import com.xbongbong.saas.enums.SetTypeEnum;
import com.xbongbong.saas.enums.ShowTypeEnum;
import lombok.Getter;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 * 成本调整单枚举
 *
 * @author WuHB
 * @date 2021/11/17 15:41
 */
@Getter
public enum CostAdjustEnum {

    // 基础信息
    BASE_INFO("other_1", "enum.costAdjust.attrName.base_info", "baseInfo", FieldTypeEnum.SEPARATOR.getType(), SetTypeEnum.DISABLE_REPEAT.getCode(), 1, 0, ShowTypeEnum.EDIT_DETAIL.getCode(), 100, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    // 调整单编号
    ADJUST_NO("serialNo", "enum.costAdjust.attrName.adjust_no", "adjustNo", FieldTypeEnum.SERIALNO.getType(), SetTypeEnum.DISABLE_ALL.getCode(), 1, 0, ShowTypeEnum.ALL.getCode(), 200, 1, 1, ScreenTypeEnum.SCREEN_GROUP.getType()),
    // 调整日期
    ADJUST_TIME("date_1", "enum.costAdjust.attrName.adjust_time", "adjustTime", FieldTypeEnum.DATETIME.getType(), SetTypeEnum.DISABLE_ALL.getCode(), 1, 0, ShowTypeEnum.ALL.getCode(), 300, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    // 成本调整仓库
    WAREHOUSE_ID("text_81", "enum.costAdjust.attrName.warehouse_id", "warehouseId", FieldTypeEnum.LINK_BUSINESS_SINGLE.getType(), SetTypeEnum.DISABLE_REPEAT.getCode(), 0, 0, ShowTypeEnum.ALL.getCode(), 301, 1, 0, ScreenTypeEnum.SCREEN_GROUP.getType()),
    // 产品信息
    PRODUCT_INFO("other_2", "enum.costAdjust.attrName.product_info", "productInfo", FieldTypeEnum.SEPARATOR.getType(), SetTypeEnum.DISABLE_REPEAT.getCode(), 1, 0, ShowTypeEnum.EDIT_DETAIL.getCode(), 400, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    // 关联产品
    PRODUCT("array_1", "enum.costAdjust.attrName.product", "products", FieldTypeEnum.SELECT_PRODUCT.getType(), SetTypeEnum.DISABLE_OPEN.getCode(), 0, 0, ShowTypeEnum.ALL.getCode(), 500, 1, 1, ScreenTypeEnum.SCREEN_OFF.getType()),
    // 扩展信息
    EXTEND_INFO("other_3", "enum.costAdjust.attrName.extend_info", "extendInfo", FieldTypeEnum.SEPARATOR.getType(), SetTypeEnum.DISABLE_REPEAT.getCode(), 1, 0, ShowTypeEnum.EDIT_DETAIL.getCode(), 600, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    //负责人
    OWNER_ID("ownerId", "enum.costAdjust.attrName.owner_id", "ownerId", FieldTypeEnum.OWNERID.getType(), SetTypeEnum.DISABLE_ALL.getCode(), 1, 0, ShowTypeEnum.ALL.getCode(), 700, 1, 1, ScreenTypeEnum.SCREEN_GROUP.getType()),
    //备注
    MEMO("text_7", "enum.costAdjust.attrName.memo", "memo", FieldTypeEnum.TEXTAREA.getType(), SetTypeEnum.DISABLE_REPEAT.getCode(), 0, 0, ShowTypeEnum.ALL.getCode(), 800, 1, 0, ScreenTypeEnum.SCREEN_SHOW.getType()),
    // 系统信息
    SYSTEM_INFO("other_4", "enum.costAdjust.attrName.system_info", "systemInfo", FieldTypeEnum.SEPARATOR.getType(), SetTypeEnum.DISABLE_REPEAT.getCode(), 1, 0, ShowTypeEnum.EDIT_DETAIL.getCode(), 900, 1, 0, ScreenTypeEnum.SCREEN_OFF.getType()),
    // 创建人
    CREATOR_ID("creatorId", "enum.costAdjust.attrName.creator_id", "creatorId", FieldTypeEnum.CREATORID.getType(), SetTypeEnum.DISABLE_ALL.getCode(), 0, 0, ShowTypeEnum.ALL.getCode(), 1000, 1, 0, ScreenTypeEnum.SCREEN_GROUP.getType()),
    // 创建时间
    ADD_TIME("addTime", "enum.costAdjust.attrName.add_time", "addTime", FieldTypeEnum.ADDTIME.getType(), SetTypeEnum.DISABLE_ALL.getCode(), 1, 0, ShowTypeEnum.ALL.getCode(), 1100, 1, 0, ScreenTypeEnum.SCREEN_GROUP.getType()),
    // 修改时间
    UPDATE_TIME("updateTime", "enum.costAdjust.attrName.update_time", "updateTime", FieldTypeEnum.UPDATETIME.getType(), 1, 1, 0, ShowTypeEnum.ALL.getCode(), 1200, 1, 0, ScreenTypeEnum.SCREEN_GROUP.getType()),
    // 调整单仓库关联显示值
    WAREHOUSE_ID_LINKED_TEXT("text_82", "enum.costAdjust.attrName.warehouse_id_linked_text", "warehouseIdLinkedText", FieldTypeEnum.TEXT.getType(), 1, 0, 1, ShowTypeEnum.NONE.getCode(), 1300, 0, 0, ScreenTypeEnum.SCREEN_OFF.getType()),

    ;

    CostAdjustEnum(String attr, String attrName, String saasAttr, Integer fieldType, Integer setType, Integer designEditable,
                   Integer editHide, Integer showType, Integer sort, Integer visible, Integer required, Integer screenType) {
        this.attr = attr;
        this.attrName = attrName;
        this.saasAttr = saasAttr;
        this.fieldType = fieldType;
        this.setType = setType;
        this.designEditable = designEditable;
        this.editHide = editHide;
        this.showType = showType;
        this.sort = sort;
        this.visible = visible;
        this.required = required;
        this.screenType = screenType;
    }

    /**
     * 英文名称
     */
    private String attr;
    /**
     * 中文名称
     */
    private String attrName;
    /**
     * 对应saas中的attr
     */
    private String saasAttr;
    /**
     * 字段类型，详见
     *
     * @see com.xbongbong.paas.enums.FieldTypeEnum
     */
    private Integer fieldType;
    /**
     * 重命名、判重、启用必填等权限
     * 1.重命名+字段权限
     * 2.重命名+字段权限+查重
     * 3.重命名+字段权限+启用、必填
     * 4.重命名+字段权限+查重+启用、必填
     * 注：pro中启用和必填是同一个权限，同时启用或同时关闭
     */
    private Integer setType;
    /**
     * 模板设计阶段字段是否允许编辑
     * 1：允许编辑
     * 0：不允许编辑
     */
    private Integer designEditable;
    /**
     * 字段是否显示在模板设计界面
     * 1：不显示
     * 0：显示
     */
    private Integer editHide;
    /**
     * 字段在各个界面（新建、编辑、列表、详情）的展现形式
     * 详见
     *
     * @see com.xbongbong.saas.enums.ShowTypeEnum
     */
    private Integer showType;
    /**
     * 字段在模板设计界面的排序
     * 建议不要用连续的数字，可以用等差数列，以防以后在两个字段之间加入新字段
     */
    private Integer sort;
    /**
     * 字段在各个界面是否可见(启用)
     * 1：可见
     * 0：不可见
     * 注：字段在具体页面的可见性需要用属性和showType联合判断，在visible=1的情况下判断showType
     */
    private Integer visible;
    /**
     * 字段是否必填
     * 1：必填
     * 0：不必填
     */
    private Integer required;
    /**
     * 筛选类型
     * 1：可筛选
     * 2：不可筛选
     */
    private Integer screenType;

    /**
     * 对data内的字段拼上“data.”
     *
     * @param cache
     * @return
     */
    public static String getAttrConnectData(CostAdjustEnum cache) {
        return "data." + cache.getAttr();
    }

    /**
     * @description 默认标签
     * @param
     * @return java.util.List<java.lang.Object>
     *
     * @creator jiantao.xiong
     * @date 2019/12/18 15:00
     *
     */
    public static List<Object> getLabelAttrList() {
        return Collections.singletonList(OWNER_ID);
    }

    /**
     * app端详情默认标题显示字段
     */
    public static List<Object> getTitleAttrList() {
        return Collections.singletonList(ADJUST_NO);
    }
    /**
     * app端详情默认标题显示字段
     */
    public static List<Object> getSummaryAttrList() {
        return Arrays.asList(OWNER_ID, ADJUST_TIME);
    }

    public String getAttrName() {
        return I18nMessageUtil.getMessage(attrName);
    }

    public static String getI18nValue(String value) {
        return I18nMessageUtil.getMessage(value);
    }

    public static List<String> getNonEditableList() {
        return Arrays.asList(ADJUST_TIME.getAttr(), PRODUCT.getAttr(),CREATOR_ID.getAttr());
    }
}
